CurrencyUtil

Miscellaneous currency functions (mostly conversion).

Properties

Link copied to clipboard

Compare two currency types so that they can be sorted by case-sensitive name

Comparator similar to CURRENCY_TYPENAME_COMPARATOR but case-insensitive

Link copied to clipboard

Compare two currency types so that they can be sorted by type and then by case-sensitive name

Functions

Link copied to clipboard
fun allMatchesForSearch(book: AccountBook, search: CurrencySearch, excludeHidden: Boolean = false, sortComparator: Comparator<CurrencyType>? = null): List<CurrencyType>

Return a list of currencies matching the given search filter

Link copied to clipboard
fun convertToBasePrice(priceFromCurr: Double, curr: CurrencyType, date: Int): Double

Convert the given price (in terms of the given currency) to a price in terms of the base currency.

Link copied to clipboard
fun convertValue(value: Long, fromCurrency: CurrencyType, toCurrency: CurrencyType): Long

Return the amount of toCurrency that the given value of fromCurrency is currently worth.

fun convertValue(value: Long, fromCurrency: CurrencyType, toCurrency: CurrencyType, userRate: Double): Long

Return the amount of 'toCurrency' obtained by exchanging 'value' of 'fromCurrency' at the rate 'rate'

fun convertValue(value: Long, fromCurrency: CurrencyType, toCurrency: CurrencyType, effectiveDate: Int): Long

Return the amount of toCurrency that the given value of fromCurrency was worth on the given date.

Link copied to clipboard
Link copied to clipboard
fun getRawRate(fromCurrency: CurrencyType?, toCurrency: CurrencyType?): Double

Get the raw (adjusted for decimal place differences) rate between the two currencies.

fun getRawRate(fromCurrency: CurrencyType, toCurrency: CurrencyType, userRate: Double): Double

Convert the given user-identifiable rate to the 'raw' rate used to exchange amounts between the given two currencies.

fun getRawRate(fromCurrency: CurrencyType, toCurrency: CurrencyType, effectiveDate: Int): Double

Get the raw (adjusted for decimal place differences) rate between the two currencies. The rate that is used is the one effective on the given date.

Link copied to clipboard
fun getSecurityBalance(book: AccountBook, security: CurrencyType, excludeInactiveAccounts: Boolean = false, asOfDate: Int? = null): Long

Get the balance / security holding (quantity) for the given security (currency). Optionally specify the asof date (default = today/balance). This will iterate all security accounts for the given security and total the security holdings...

Link copied to clipboard

Get the price (going rate) for currency curr1 in terms of curr2 on the given date. This adjusts the price to be in terms of splits in either currency so that the price is in terms of today's units of each currency (but the price is from the given date, not today's prices).

Link copied to clipboard
fun getUserRate(fromCurrency: CurrencyType?, toCurrency: CurrencyType?): Double

Get the current user-identifiable rate from fromCurrency to toCurrency.

fun getUserRate(fromCurrency: CurrencyType, toCurrency: CurrencyType, rawRate: Double): Double

Convert the given raw rate to the user-identifiable rate used to exchange amounts between the given two currencies.

fun getUserRate(fromCurrency: CurrencyType, toCurrency: CurrencyType, effectiveDate: Int): Double

Get the raw (adjusted for decimal place differences) rate between the two currencies. The rate that is used is the one effective on the given date.

Link copied to clipboard
fun parseCurrencyExpression(str: String, dec: Char, toCurr: CurrencyType, currTable: CurrencyTable?, insertDecimal: Boolean = false, asOfDate: Int = 0): Long